﻿using System;
using Microsoft.WindowsAzure.StorageClient;

namespace AzureContrib.WindowsAzure.StorageClient
{
	/// <summary>
	/// Abstraction over a <see cref="CloudQueue"/>
	/// </summary>
	/// <typeparam name="T"></typeparam>
	public interface IQueue<T>
	{
		/// <summary>
		/// <see cref="CloudQueue.AddMessage(CloudQueueMessage)"/> but we add a <see cref="CloudQueueMessage{T}"/> with a nice paylod <typeparamref name="T"/>.
		/// </summary>
		/// <param name="queueMessage">The message to enqueue</param>
		void Enqueue(CloudQueueMessage<T> queueMessage);

		/// <summary>
		/// <see cref="CloudQueue.GetMessage()"/> as a <see cref="CloudQueueMessage{T}"/>
		/// </summary>
		/// <param name="visibilityTimeout">The dequeue time</param>
		/// <returns><see cref="CloudQueueMessage{T}"/></returns>
		CloudQueueMessage<T> Dequeue(TimeSpan visibilityTimeout);

		/// <summary>
		/// Delete a message from the queue.
		/// </summary>
		/// <param name="toDelete">The message to delete.</param>
		void Delete(CloudQueueMessage<T> toDelete);

		/// <summary>
		/// <see cref="CloudQueue.PeekMessage"/>
		/// </summary>
		/// <returns>True if there is a message in the queue.</returns>
		bool HasMessages();
	}
}